package com.jiukuaidao.zhulin.module.user;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.jiukuaidao.library.base.BaseActivity;
import com.jiukuaidao.library.util.ImageGlideUtils;
import com.jiukuaidao.library.util.ToastUtil;
import com.jiukuaidao.zhulin.AppContext;
import com.jiukuaidao.zhulin.R;
import com.jiukuaidao.zhulin.util.UserInfoUtil;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Author : PaiTaSuo
 * Date : 2016/6/30
 * Description :
 */
public class SettingActivity extends BaseActivity {

    @BindView(R.id.titile_left_imageview)
    ImageView mLeftImg;
    @BindView(R.id.titile_text)
    TextView mTitileText;
    @BindView(R.id.setting_version)
    TextView mSettingVersion;
    @BindView(R.id.rl_update)
    RelativeLayout mRlUpdate;
    @BindView(R.id.rl_clear_cache)
    RelativeLayout mRlClearCache;
    @BindView(R.id.rl_setting_comment)
    RelativeLayout mRlComment;
    @BindView(R.id.but_unlogin)
    Button mButUnlogin;

    @Override
    protected View getTargetView() {
        return null;
    }

    @Override
    protected int getContentLayoutId() {
        return R.layout.activity_setting;
    }

    @Override
    protected void handleBundle(Bundle bundle) {

    }

    @Override
    protected void init() {
        mTitileText.setText(getResources().getString(R.string.setting));
        if (UserInfoUtil.isLogin()) {
            mButUnlogin.setVisibility(View.VISIBLE);
        } else {
            mButUnlogin.setVisibility(View.GONE);
        }
    }


    @OnClick(R.id.titile_left_imageview)
    public void clickLeftBack() {
        this.finish();
    }

    @OnClick(R.id.but_unlogin)
    public void setButUnlogin() {
        UserInfoUtil.setLogin(false);
        finish();
    }

    @OnClick(R.id.rl_update)
    public void setUpdate() {
        //待添加检查更新逻辑
        ToastUtil.show(getResources().getString(R.string.setting_update_hint), Toast.LENGTH_SHORT);
    }

    @OnClick(R.id.rl_clear_cache)
    public void setClearCache() {
        // 清除缓存
        ImageGlideUtils.ClearCache(AppContext.getContext());
        ToastUtil.show(getResources().getString(R.string.setting_clear_success), Toast.LENGTH_SHORT);
    }

    @OnClick(R.id.rl_setting_comment)
    public void setComment() {
        ToastUtil.show("开发中", Toast.LENGTH_SHORT);
    }
}
